package org.dromara.assets.service.impl;

import java.util.List;

import org.dromara.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.dromara.assets.mapper.AssetsAccountMapper;
import org.dromara.assets.domain.AssetsAccount;
import org.dromara.assets.service.IAssetsAccountService;
import com.baomidou.dynamic.datasource.annotation.DS;

/**
 * 交易所账号Service业务层处理
 *
 * @author ruoyi
 * @date 2022-08-25
 */
@Service
public class AssetsAccountServiceImpl implements IAssetsAccountService {
    @Autowired
    private AssetsAccountMapper assetsAccountMapper;

    /**
     * 查询交易所账号
     *
     * @param id 交易所账号主键
     * @return 交易所账号
     */
    @Override
    public AssetsAccount selectAssetsAccountById(Long id) {
        return assetsAccountMapper.selectAssetsAccountById(id);
    }

    /**
     * 查询币安状态为正常账号列表
     *
     * @return 币安状态为正常账号列表
     */
    @DS("assets")
    @Override
    public List<AssetsAccount> selectAssetsAccountList4Binance() {
        AssetsAccount assetsAccount = new AssetsAccount();
        assetsAccount.setPlatform(1L);
        assetsAccount.setStatus(1);
        return assetsAccountMapper.selectAssetsAccountList(assetsAccount);
    }

    /**
     * 查询交易所账号列表
     *
     * @param assetsAccount 交易所账号
     * @return 交易所账号
     */
    @Override
    @DS("assets")
    public List<AssetsAccount> selectAssetsAccountList(AssetsAccount assetsAccount) {
        return assetsAccountMapper.selectAssetsAccountList(assetsAccount);
    }

    /**
     * 新增交易所账号
     *
     * @param assetsAccount 交易所账号
     * @return 结果
     */
    @Override
    public int insertAssetsAccount(AssetsAccount assetsAccount) {
        assetsAccount.setCreateTime(DateUtils.getNowDate());
        return assetsAccountMapper.insertAssetsAccount(assetsAccount);
    }

    /**
     * 修改交易所账号
     *
     * @param assetsAccount 交易所账号
     * @return 结果
     */
    @Override
    public int updateAssetsAccount(AssetsAccount assetsAccount) {
        assetsAccount.setUpdateTime(DateUtils.getNowDate());
        return assetsAccountMapper.updateAssetsAccount(assetsAccount);
    }

    /**
     * 批量删除交易所账号
     *
     * @param ids 需要删除的交易所账号主键
     * @return 结果
     */
    @Override
    public int deleteAssetsAccountByIds(Long[] ids) {
        return assetsAccountMapper.deleteAssetsAccountByIds(ids);
    }

    /**
     * 删除交易所账号信息
     *
     * @param id 交易所账号主键
     * @return 结果
     */
    @Override
    public int deleteAssetsAccountById(Long id) {
        return assetsAccountMapper.deleteAssetsAccountById(id);
    }
}
